// Copyright 2022 Huawei Cloud Computing Technology Co., Ltd.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

const PROTOCOL_CONFIG = {
    MSG_TYPE: {
        INVALID: 0, // 无效
        VERIFY: 1, // 认证
        AUDIO: 2, // 音频数据
        VIDEO: 3, // 视频编码后数据
        CHANNEL: 4, //双向数据通道
        TOUCH: 6, // 触摸数据
        CMD_CONTROL: 7, // 控制指令
        HEART_BEAT: 8, // 心跳数据
        ORIENTATION: 9, // 旋转
        ORIENTATION_TimeStamp: 10, // 旋转与出帧时间
        KEYBOARD_INPUT: 14, // 远程输入法
        CAMERA: 21, // 摄相头
        MICROPHONE: 22, // 麦克风
        SENSOR: 23 // 传感器
    },
    CAMERA_MESSAGE_TYPE: {
        OPT_CAMERA_GET_PARAM_REQ: 0x1,
        OPT_CAMERA_GET_PARAM_RSP: 0x1001,
        OPT_CAMERA_SET_PARAM_REQ: 0x2,
        OPT_CAMERA_SET_PARAM_RSP: 0x1002,
        OPT_CAMERA_GET_INFO_REQ: 0x3,
        OPT_CAMERA_SET_INFO_RSP: 0x1003,
        OPT_CAMERA_START_PREVIEW_REQ: 0x4,
        OPT_CAMERA_START_PREVIEW_RSP: 0x1004,
        OPT_CAMERA_STOP_PREVIEW_REQ: 0x5,
        OPT_CAMERA_STOP_PREVIEW_RSP: 0x1005,
        OPT_CAMERA_IS_SUPPORT_H264_REQ: 0x6,
        OPT_CAMERA_IS_SUPPORT_H264_RSP: 0x1006,
        OPT_CAMERA_GET_SIZE_REQ: 0x7,
        OPT_CAMERA_GET_SIZE_RSP: 0x1007,
        OPT_CAMERA_FRAME: 0x8,
        OPT_INVALID: 0x9
    },
    MICROPHONE_MESSAGE_TYPE: {
        OPT_MIC_START_RECORD_REQ: 0x1,
        OPT_MIC_STOP_RECOED_REQ: 0x2,
        OPT_MIC_SET_PARAM_REQ: 0x3,
        OPT_MIC_AUDIO_FRAME: 0x10,
        OPT_MIC_START_RECORD_RSP: 0x1001,
        OPT_MIC_STOP_RECOED_RSP: 0x1002,
        OPT_MIC_SET_PARAM_RSP: 0x1003
    },
    SENSOR_MESSAGE_TYPE: {
        OPT_SENDOR_ENABLE_REQ: 0x1,
        OPT_SENSOR_ENABLE_RSP: 0x1001,
        OPT_SENSOR_DISABLE_REQ: 0x2,
        OPT_SENSOR_DISABLE_RSP: 0x1002,
        OPT_SENSOR_DATA: 0x10,
        TYPE_ACCELEROMETER: 0,
        TYPE_GYROSCOPE: 1
    },
    CMD_TYPE: {
        VERIFY: '0',
        START: '1',
        STOP: '2',
        RECONNECT: '3',
        PAUSE: '4',
        RESUME: '5',
        SET_MEDIA_CONFIG: '7',
    },
    CMD_RESULT: {
        FAIL: '0',
        SUC: '1'
    },
    CMD_RESP_TYPE: {
        CONNECT_FAILED: 0x0301,
        VERIFY_FAILED: 0x0606,
        START_FAILED: 0x0904,
        PAUSE_TIMEOUT: 0x1000,
        PLAY_TIMEOUT: 0x0E00,
        TOUCH_TIMEOUT: 0x0F00,
        MEDIA_CONFIG_SUCCESS: 0x2100,
        START_SUCCESS: 0x0800,
        RECONNECT_PARAMETER_INVALID: 0x0D01,
        RECONNECT_SERVER_UNREACHABLE: 0x0D02,
        RECONNECT_ENGING_START_ERROR: 0x0D03,
        H265_NOT_SUPPORT: 0x1102,
        VERIFY_SESSION_ID_INVALID: 0x0607,
        INVALID_OPERATION: 0xFFFF,
    },
    ACTIONS_TYPE: {
        DOWN: 0,
        UP: 1,
        MOVE: 2,
        POINTER_DOWN: 5,
        POINTER_UP: 6
    },
    HEADER_LENGTH: 8,
    ORIENTATION: {
        0: 'PORTRAIT',
        1: 'LANDSCAPE', // 从竖屏逆时针旋转90度
        8: 'REVERSE_LANDSCAPE',
        24: 'LANDSCAPE',
        16: 'REVERSE_PORTRAIT'
    },
    RESOLUTIONS: {
        DISPLAY_480P: {
            width: 480,
            height: 848
        },
        DISPLAY_540P: {
            width: 544,
            height: 960
        },
        DISPLAY_720P: {
            width: 720,
            height: 1280
        },
        DISPLAY_1080P: {
            width: 1080,
            height: 1920
        }
    },
    'UHD': {
        quality: 'best'
    },
    'HD': {
        quality: 'main'
    },
    'SD': {
        quality: 'basic'
    },
    DEFAULT_RESOLUTION: {
        width: 720,
        height: 1280
    },
    KEYBOARD_INPUT_MSG_TYPE: {
        INPUT_EVENT: 0X00,
        HIDE_KEYBOARD_EVENT: 0X01,
        TEXT_UPDATE: 0X02
    },
    KEYBOARD_INPUT_HEADER_LENGTH:3,
    REMOTE_IME: {
        CLOUD_PHONE_KEYBOARD: '0',
        CLIENT_KEYBOARD: '1'
    },
    PHONE_CONNECTION_STATE: {
        1: {
            state: 1,
            message: 'The Phone has been connected by other user.'
        },
        2: {
            state: 2,
            message: 'Connection number exceeds the limit.'
        },
        3: {
            state: 3,
            message: 'Connection to phone failed.'
        },
        4: {
            state: 4,
            message: 'No operations for a long time.'
        },
        5: {
            state: 5,
            message: 'Please log in to the cloud phone again.'
        }
    }
};

export default PROTOCOL_CONFIG;
